package com.hgd.security.evp.swagger.config;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.http.HttpOutputMessage;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageNotWritableException;
import springfox.documentation.spring.web.json.Json;

import java.io.IOException;
import java.lang.reflect.Type;

/**
 * @author ：尚村山夫
 * @date ：Created in 2019/8/13 22:52
 * @modified By：
 */
public class Hgd11FastJsonHttpMessageConverter extends FastJsonHttpMessageConverter {

    @Override
    public void write(Object o, Type type, MediaType contentType, HttpOutputMessage outputMessage)
        throws IOException, HttpMessageNotWritableException {
        if(o instanceof Json){
            Json json = (Json) o;
            String value = json.value();
            JSONObject jsonObject = JSONObject.parseObject(value);
            JSONObject definitions = jsonObject.getJSONObject("definitions");
            System.out.println(value);
        }
        super.write(o, type, contentType, outputMessage);
    }

//    @Override
//    public void registerBeanDefinitions(AnnotationMetadata annotationMetadata,
//        BeanDefinitionRegistry beanDefinitionRegistry) {
//
//    }
}
